home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / buffr2.zip / BD4ARRAY.PAS < prev    next >
Pascal/Delphi Source File  |  1993-01-04  |  4KB  |  112 lines

  1. Unit BD4Array;  {Useable 4-Dimensional BufferedArrays}
  2. {$R-}
  3.  
  4. INTERFACE
  5. Uses BD4_Max;
  6.  
  7. Type
  8.   BD4_IntArray = Object (D4_BufferedArray)
  9.  
  10.                    Procedure Init (Max1,Max2,Max3,Max4,MaxBuffSize : LongInt;
  11.                                   FileName : String);
  12.  
  13.                    { BD4_xxxArrays are indexed 0..Max1-1, 0..Max2-1}
  14.                                               {0..Max3-1, 0..Max4-1}
  15.  
  16.                    Procedure Load (FileName : String;
  17.                                    Max1,Max2,Max3,Max4,MaxBuffSize : LongInt);
  18.  
  19.                    Procedure Accept (W,X,Y,Z : LongInt; I : Integer);
  20.  
  21.                    Procedure Retrieve (W,X,Y,Z : LongInt; Var I : Integer);
  22.  
  23.                    {NOTE: There is no reason why Retrieve could not be}
  24.                    {redefined as a function for atomic types such as Integer}
  25.  
  26.                    Procedure Copy (From : BD4_IntArray);
  27.                               {Target *MUST* already be initialized}
  28.                               {to the EXACT same parameters as From}
  29.                               {this will save checking for sufficient}
  30.                               {available Memory!}
  31.  
  32. (* no redefinition needed
  33.  
  34.                    Procedure Store;
  35.  
  36.                    Procedure Swap (W1,X1,Y1,Z1,W2,X2,Y2,Z2 : LongInt);
  37.                               {Swap the 1 and 2 Element}
  38.  
  39.                    Function MaxIndex (Index : Byte) : LongInt;
  40.                                      {Return the Max legal Index}
  41.                                      {for the Indexth Dimension}
  42.  
  43.                    Function MaxSize : LongInt;
  44.                                       {Report Number of Array Elements}
  45.                    Function ElemSize : Word;  {Report Element Size}
  46.                    Procedure Destroy;
  47. *)
  48.           End; {BD4_IntArray}
  49.  
  50. IMPLEMENTATION
  51.  
  52. Uses BND_Max;  {Obtain the definition of the DimensionPtr Type}
  53.  
  54. Procedure BD4_IntArray.Init;
  55. {NOTE: If ANY of the Max's is zero, ND_MAX.INIT will attempt}
  56. {to determine and allocate the maximum possible index.  If all}
  57. {are zero, then the largest possible evenly-indexed array will be allocated}
  58. {There is a POSSIBILITY of allocation errors if less than all are}
  59. {zero, but such errors will be detected and reported}
  60. Var
  61.   Temp : DimensionPtr;
  62.   I    : Byte;
  63. Begin
  64.   I := 0;
  65.   GetMem (Temp,4*SizeOf(LongInt));
  66.   Temp^[I] := Max1; I := 1;  {Have to fool the compiler, even}
  67.   Temp^[I] := Max2; I := 2;  {with Range-checking off!!}
  68.   Temp^[I] := Max3; I := 3;
  69.   Temp^[I] := Max4;
  70.   D4_BufferedArray.Init (Temp,SizeOf(Integer),MaxBuffSize,FileName);
  71.   FreeMem (Temp,4*SizeOf(LongInt));
  72. End;
  73.  
  74. Procedure BD4_IntArray.Load;
  75. Var
  76.   Temp : DimensionPtr;
  77.   I    : Byte;
  78. Begin
  79.   I := 0;
  80.   GetMem (Temp,4*SizeOf(LongInt));
  81.   Temp^[I] := Max1; I := 1;  {Have to fool the compiler, even}
  82.   Temp^[I] := Max2; I := 2;  {with Range-checking off!!}
  83.   Temp^[I] := Max3; I := 3;
  84.   Temp^[I] := Max4;
  85.   D4_BufferedArray.Load (FileName,SizeOf(Integer),MaxBuffSize,4,Temp);
  86.   FreeMem (Temp,4*SizeOf(LongInt));
  87. End;
  88.  
  89. Procedure BD4_IntArray.Accept (W,X,Y,Z : LongInt; I : Integer);
  90. Var
  91.   Temp : Integer;
  92. Begin
  93.   Temp := I;
  94.   D4_BufferedArray.Accept (W,X,Y,Z,Temp,SizeOf(Integer))
  95. End;
  96.  
  97. Procedure BD4_IntArray.Retrieve (W,X,Y,Z : LongInt; Var I : Integer);
  98. Var
  99.   Temp : Integer;
  100. Begin
  101.   D4_BufferedArray.Retrieve (W,X,Y,Z,Temp,SizeOf(Integer));
  102.   I := Temp
  103. End;
  104.  
  105. Procedure BD4_IntArray.Copy (From : BD4_IntArray);
  106. {Redefined purely for type-checking}
  107. Begin
  108.   D4_BufferedArray.Copy (From)
  109. End;
  110.  
  111. BEGIN
  112. END.